#ifndef _OI_PLSCANNERCORE_OUTPUT_HPP_
#define _OI_PLSCANNERCORE_OUTPUT_HPP_

#include "PLScannerCore/OiPLScannerCore.hpp"
#include "PLScannerCore/OiPLScannerWorker.hpp"
#include "PLScannerCore/Database/OiDatabase.hpp"

namespace Oi
{
    namespace PLScannerCore
    {
        class OI_PLSCANNER_CORE_API PLScannerOutput
        {
        public:
            static bool  saveToSys(const WorkResult::Result& r, const QString name);
            static bool saveToSys(const DataRow& r, const QString name);
            static bool saveToSys(const FixedValueRow& r, const QString name);
            static bool  saveToSys(const QString n, double v, int r, const QString name);
            static bool  heartbeat(int value, const QString name);
        };

        class OI_PLSCANNER_CORE_API OutputWriter
        {
        public:
            virtual ~OutputWriter() {}

        public:
            virtual  bool ready() = 0;

        public:
            virtual bool output(const WorkResult::Result&) = 0;
            virtual bool output(const DataRow&) = 0;
            virtual bool output(const FixedValueRow&) = 0;
            virtual bool output(const QString , const double, const int) = 0;

        public:
            virtual bool heartbeat(int) = 0;

        public:
            static QSharedPointer<OutputWriter> create(QString name);
        };

        class OI_PLSCANNER_CORE_API OutputWriterSystem
        {
        public:
            OutputWriterSystem();

        public:
            QSharedPointer<OutputWriter> writer(QString name);

        public:
            void clear();

        public:
            void addWriter(QString name, QSharedPointer<OutputWriter>);

        public:
            static OutputWriterSystem* instance();

        private:
            OI_DISABLE_COPY(OutputWriterSystem);
            OI_DECLARE_IMPL(OutputWriterSystem);
        };
    }
}

#endif
